<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="functions.asp" -->
<%
'on error resume next
'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTTEST2", "MP2", "MP2"

dim sql
dim i

if (request.querystring("type")="blocked") then
sql= "SELECT * FROM EXILINKRCP WHERE SEQNUM=" & request.querystring("seqnum")
set rs=cn.execute(sql)

do while not rs.eof

 sql = "EXEC dbo.EXIPORECUPDATE "
 sql = sql & "@InvoiceStatus='',"
 sql = sql & "@InvoiceNum='',"
 sql = sql & "@InvoiceDate='',"
 sql = sql & "@PONumber='" & rs("PONUM") & "',"
 sql = sql & "@ReceiverNum='" & rs("RECEIVERNUM") & "'"
	  
 cn.execute(sql)
rs.movenext
Loop
set rs=nothing

'update EXIREG	
sql = "UPDATE EXIREG SET INVSTATUS='BLOCKED' WHERE SEQNUM=" & request.querystring("seqnum")
cn.execute(sql)

sql = "SELECT TOP 1 * FROM EXIHIST WHERE SEQNUM=" & request.querystring("seqnum") & " ORDER BY DATE DESC"
set rs=cn.execute(sql)

'update EXIHIST
  sql = "INSERT INTO EXIHIST (SEQNUM, TRANSTYPE,LOCATION,DEPARTMENT,DATE,UPDATEUSER,UPDATESTAMP)"
  sql = sql & " VALUES ("
  sql = sql & request.querystring("seqnum") & ",'"
  sql = sql & "IBL','"
  sql = sql & rs("LOCATION") & "','"
  sql = sql & rs("DEPARTMEnT") & "',"
  sql = sql & "GETDATE(),'"
  sql = sql & usrName & "',"
  sql = sql & "GETDATE() )"
  
  cn.execute(sql)
 set rs=nothing

response.redirect "Inv_Detail.asp?seqnum="& request.querystring("seqnum")
'------------------------------------------------------------- end of blocking process
else

  sql= "SELECT * FROM EXILINKRCP WHERE SEQNUM=" & request.querystring("seqnum")
  set rs=cn.execute(sql)

  do while not rs.eof

  sql = "EXEC dbo.EXIPORECUPDATE "
  sql = sql & "@InvoiceStatus='PARKED',"
  sql = sql & "@InvoiceNum='"& request.querystring("invNum")&"',"
  sql = sql & "@InvoiceDate='"& request.querystring("recDate")&"',"
  sql = sql & "@PONumber='" & rs("PONUM") & "',"
  sql = sql & "@ReceiverNum='" & rs("RECEIVERNUM") & "'"
	  
  cn.execute(sql)
  rs.movenext
  Loop
  set rs=nothing
  'update EXIREG	
  sql = "UPDATE EXIREG SET INVSTATUS='PARKED' WHERE SEQNUM=" & request.querystring("seqnum")
  cn.execute(sql)

  sql = "SELECT TOP 1 * FROM EXIHIST WHERE SEQNUM=" & request.querystring("seqnum") & " ORDER BY DATE DESC"
  set rs=cn.execute(sql)

  'update EXIHIST
  sql = "INSERT INTO EXIHIST (SEQNUM, TRANSTYPE,LOCATION,DEPARTMENT,DATE,UPDATEUSER,UPDATESTAMP)"
  sql = sql & " VALUES ("
  sql = sql & request.querystring("seqnum") & ",'"
  sql = sql & "IRC','"
  sql = sql & rs("LOCATION") & "','"
  sql = sql & rs("DEPARTMENT") & "',"
  sql = sql & "GETDATE(),'"
  sql = sql & usrName & "',"
  sql = sql & "GETDATE() )"
  
  cn.execute(sql)
  set rs=nothing

  response.redirect "Inv_Blocked.asp"
end if
%>